package com.neuedu.thread;

public class Thread03Demo {
    public static void main(String[] args) {
        Program  p1 = new Program(1000,"java程序员");
        Program  p2 = new Program(3000,"Python程序员");
        Thread  t1 = new Thread(p1);
        Thread  t2 = new Thread(p2);
        t1.start();
        t2.start();

    }
}

class Program extends  Object implements  Runnable{
    private int day=1;
    private int sleep=1000;
    private String name;

    public Program(int sleep, String name) {
        this.sleep = sleep;
        this.name = name;
    }

    @Override
    public void run() {
        while(true){
            System.out.println(name+"工作 "+(day++));
            try {
                Thread.sleep(sleep);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
